package com.r2coding.music.api;

import com.r2coding.common.util.Result;
import com.r2coding.music.entity.SongCategoryEntity;
import com.r2coding.music.service.SongCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author:98k灬
 * @since:2022/05/13 12:22
 **/
@RestController
@RequestMapping("/api/songCategory")
public class ApiSongCategoryController {
    @Autowired
    SongCategoryService songCategoryService;

    /**
     * 获取所有的歌曲分类信息
     *
     * @return 统一响应体
     */
    @GetMapping("/list")
    public Result getAllSongCategory() {
        List<SongCategoryEntity> list = songCategoryService.list();
        return Result.ok(list);
    }

    /**
     * 查询歌曲分类详情信息
     *
     * @param id 歌曲分类id
     * @return 统一响应体
     */
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable("id") Integer id) {
        SongCategoryEntity songCategory = songCategoryService.getById(id);
        return Result.ok(songCategory);
    }
}
